package rotation

import (
	"gin_demo/utility"

	"github.com/gin-gonic/gin"
)

var Rotaion = new(cRotation)

type cRotation struct{}

//@Summary  轮播图数据添加接口
//@Success 200 {string} string json{"code","message"}
//@Param data body rotation.RotationReq{} true "注册请求参数"
//@Router  /backend/rotation/add  [post]
//@version 1.0
func (a *cRotation) Create(ctx *gin.Context) {
	req := RotationReq{}
	err := ctx.ShouldBindJSON(&req)
	if err != nil {
		utility.Fail(ctx, err.Error())
	} else {
		Create(ctx, req)
	}
}

// @Summary 轮播图数据加载接口
// @Success 200 {string} string json{"code","message"}
// @Param Authorization	header string true "Bearer 31a165baebe6dec616b1f8f3207b4273"
// @Router  /backend/rotation/list [get]
// @version 1.0
func (a *cRotation) List(ctx *gin.Context) {

	List(ctx)
}

// @Summary 轮播图数据删除接口
//@Param data body rotation.SoftDeleteReq{} true "注册请求参数"
// @Success 200 {string} string json{"code","message"}
// @Param Authorization	header string true "Bearer 31a165baebe6dec616b1f8f3207b4273"
// @Router  /backend/rotation/del [delete]
// @version 1.0
func (a *cRotation) Delete(ctx *gin.Context) {

	req := SoftDeleteReq{}
	err := ctx.ShouldBindJSON(&req)
	if err != nil {
		utility.Fail(ctx, err.Error())
	} else {
		Delete(ctx, req)
	}
}

// @Summary 轮播图数据更新接口
// @Success 200 {string} string json{"code","message"}
//@Param data body rotation.UpdateRotationReq{} true "注册请求参数"
// @Param Authorization	header string true "Bearer 31a165baebe6dec616b1f8f3207b4273"
// @Router  /backend/rotation/update [put]
// @version 1.0
func (a *cRotation) Update(ctx *gin.Context) {

	req := UpdateRotationReq{}
	err := ctx.ShouldBindJSON(&req)
	if err != nil {
		utility.Fail(ctx, err.Error())
	} else {
		Update(ctx, req)
	}
}
